﻿// CSettingsDlg.cpp: 实现文件
//

#include "pch.h"
#include "AKRS.h"
#include "afxdialogex.h"
#include "CSettingsDlg.h"


// CSettingsDlg 对话框

IMPLEMENT_DYNAMIC(CSettingsDlg, CDialogEx)

CSettingsDlg::CSettingsDlg(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_SETTINGS_DIALOG, pParent)
{

}

CSettingsDlg::~CSettingsDlg()
{
}

void CSettingsDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CSettingsDlg, CDialogEx)
	ON_BN_CLICKED(IDOK, &CSettingsDlg::OnBnClickedOk)
END_MESSAGE_MAP()


// CSettingsDlg 消息处理程序

#define IDC_CHECKi IDC_CHECK1 - 1 + i
void CSettingsDlg::OnBnClickedOk()
{
	// TODO: 在此添加控件通知处理程序代码
	for (int i = 1; i <= SettingCounts; i++)
	{
		CButton* pBtn = (CButton*)GetDlgItem(IDC_CHECKi);
		int state = pBtn->GetCheck();
		SettingsValue[i] = state == SettingsValue[i] ? SettingsValue[i] : !SettingsValue[i];
	}

	CDialogEx::OnOK();
}


BOOL CSettingsDlg::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  在此添加额外的初始化

	for (int i = 1; i <= SettingCounts; i++)
	{
		if (SettingsValue[i] == true)
		{
			CButton* pBtn = (CButton*)GetDlgItem(1004 + i);//直接使用资源符号值
			pBtn->SetCheck(true);
		}
	}
	

	return TRUE;  // return TRUE unless you set the focus to a control
	// 异常: OCX 属性页应返回 FALSE
}
